package sql;
import bean.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.jdbc.SQL;
public class ReturnSql {
    //定义方法，返回查询的sql语句
    public String getSelectAll(){
        return new SQL(){
            {
                SELECT("*");
                FROM("student");
            }
        }.toString();
    }

    public String getInsert(Student stu){
        return new SQL(){
            {
                INSERT_INTO("student");
                INTO_VALUES("#{sid},#{name},#{age},#{birthday}");
            }
        }.toString();
    }

    public String getUpdate(String stu){
        return new SQL(){
            {
                UPDATE("student");
                SET("name=#{name}","age=#{age}","birthday=#{birthday}");
                WHERE("sid=#{sid}");
            }
        }.toString();
    }
    public String getDelete(Integer id){
        return new SQL(){
            {
                DELETE_FROM("student");
                WHERE("sid=#{sid}");
            }
        }.toString();
    }
}
